package com.zhouhailin.stream.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

/**
 * 流操作--过滤
 *
 * @Author zhouhailin
 * @date 2023/1/17 13:53
 */
public class FilterStreamDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("乔丹");
        list.add("科比");
        list.add("詹姆斯");

        // 筛选出具有“科”的字符串
        Stream<String> stream = list.stream().filter(element -> element.contains("科"));
        // 遍历
        stream.forEach(System.out::println);
    }
}
